/*    */ package com.szsky.sky.demo;
/*    */ 
/*    */ import java.io.UnsupportedEncodingException;
/*    */ import java.security.MessageDigest;
/*    */ import org.apache.commons.codec.binary.Hex;
/*    */ import org.apache.commons.codec.digest.DigestUtils;
/*    */ import org.apache.commons.lang3.StringUtils;
/*    */ import org.springframework.security.crypto.password.PasswordEncoder;
/*    */ 
/*    */ 
/*    */ public class BspMd5PasswordEncoder
/*    */   implements PasswordEncoder
/*    */ {
/* 15 */   private final String salt = "1#2$3%4(5)6@7!poeeww$3%4(5)djjkkldss";
/*    */   
/*    */   public String encode(CharSequence rawPassword) {
/* 18 */     MessageDigest md = DigestUtils.getMd5Digest();
/* 19 */     String saltRaw = (new StringBuilder(rawPassword)).append("{").append("1#2$3%4(5)6@7!poeeww$3%4(5)djjkkldss").append("}").toString();
/*    */     
/*    */     try {
/* 22 */       return Hex.encodeHexString(md.digest(saltRaw.getBytes("utf-8")));
/* 23 */     } catch (UnsupportedEncodingException e) {
/* 24 */       throw new RuntimeException("字符集错误", e);
/*    */     } 
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public boolean matches(CharSequence rawPassword, String encodedPassword) {
/* 31 */     String epassword = encode(rawPassword);
/* 32 */     return StringUtils.equalsIgnoreCase(epassword, encodedPassword);
/*    */   }

    public static void main(String[] args) {
        System.out.println(new BspMd5PasswordEncoder().encode("Rongji@123"));
    }
/*    */ }


/* Location:              D:\li.sun\cod\\uum-app-kz97p-769bc6745c-2rs4l-boot\BOOT-INF\classes\!\com\inspur\est\mv\\uum\security\BspMd5PasswordEncoder.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */